<?php


function list_karyawan_by_periode_id(){
	$periode_id =get_periode_absen();
	$periode = my_get_data_by_id('pr_periode','periode_id',$periode_id);
	$bulan = (int) date('m' , strtotime($periode['tanggal']));
	$tahun = (int) date('Y' , strtotime($periode['tanggal']));
	$end=$periode['tahun'].'-'. sprintf( '%02d',$bulan) .'-10' ;
	$header1 = array(
		'#'=>array('style'=>'border-bottom:2px solid;width:3%'),
		'nik'=>array('style'=>'border-bottom:2px solid;width:8%'),
		'nama'=>array('style'=>'border-bottom:2px solid;width:20%'),
		'WK'=>array('style'=>'border-bottom:2px solid;width:3%'),
		'KEL'=>array('style'=>'border-bottom:2px solid;width:3%'),
		  
	);
	$header2= array();
	$tanggals = list_kalender($periode['dari'] , $periode['sampai']  );
	$tanggals = array_unique($tanggals) ;
	foreach($tanggals as $tgl){ 
		$header2[date('d',strtotime($tgl) )] = array('style'=>'border-bottom:2px solid;width:1%');
	}
	$header3 = array(' '=>array('style'=>'border-bottom:2px solid;width:3%'));
	$header = $header1 + $header2 + $header3;
	if(isset($_GET['key'])){
		$query = "
			SELECT * FROM karyawan a 
			INNER JOIN biodata b 
			ON a.biodata_id = b.biodata_id
			WHERE a.karyawan_id NOT IN (select karyawan_id FROM karyawan_disable)	
			AND a.karyawan_id NOT IN (select karyawan_id FROM pemberhentian  WHERE TMT <= '{$end}') 	
			AND ( b.nama LIKE '%{$_GET['key']}%' OR a.nik='{$_GET['key']}')
			ORDER BY a.nik
		";
	}else{
		$query = "
			SELECT * FROM karyawan a 
			INNER JOIN biodata b 
			ON a.biodata_id = b.biodata_id
			WHERE a.karyawan_id NOT IN (select karyawan_id FROM karyawan_disable)	
			AND a.karyawan_id NOT IN (select karyawan_id FROM pemberhentian  WHERE TMT <= '{$end}') 	
			ORDER BY a.nik
		";
	}
	$result = my_query($query);
	$total_records = my_num_rows($result );
	$scroll_page =5;   
	$per_page =24;  
	$current_page = isset($_GET['page']) ? (int) $_GET['page'] : 1 ; 
	if($current_page < 1){
		$current_page = 1;
	}		 
	$pager_url  ="index.php?com=jadwal_wk_karyawan&task={$_GET['task']}&key={$_GET['key']}&page=";	 
	$inactive_page_tag = 'style="padding:4px;background-color:#BBBBBB"';  
	$previous_page_text = ' Mundur '; 
	$next_page_text = ' Maju ';  
	$first_page_text = ' Awal '; 
	$last_page_text = ' Akhir ';
	
	$kgPagerOBJ = new kgPager();
	$kgPagerOBJ->pager_set(
		$pager_url, 
		$total_records, 
		$scroll_page, 
		$per_page, 
		$current_page, 
		$inactive_page_tag, 
		$previous_page_text, 
		$next_page_text, 
		$first_page_text, 
		$last_page_text ,$pager_url_last); 
	 		
	$result = my_query($query ." LIMIT ".$kgPagerOBJ->start.", ".$kgPagerOBJ->per_page); 	
	$row = array(); 
	$i = ($current_page  - 1 ) * 24; 
	while($ey = my_fetch_array($result )){
		$i++;
		$karyawan =  loaddata_karyawan($ey['karyawan_id']); 
 
		$detailproperty = array(
			'href'=>'index.php?com=jadwal_wk_karyawan&task=list_detail&karyawan_id='.$ey['karyawan_id'], 
			'title'=>'Detail'
		);
		$detail_button = button_icon( 'b_props.png' , $detailproperty  ); 
		$row1 = array(
			'#'=>position_text_align ($i, 'center'), 
			'nik'=>position_text_align( $karyawan['nik'], 'center'),
			'nama'=>substr($karyawan['nama_gelar'], 0,12), 
			'wk'=>position_text_align( $karyawan['waktu_kerja'] , 'center'), 
			'kel'=>position_text_align( $karyawan['kelompok'] , 'center'), 
			 
			 
		);
		$row2  = array(); 
		foreach($tanggals as $tgl){ 
			$dt = get_kelompok_jadwal($tgl  , $karyawan['waktu_kerja_id'] , $karyawan['kelompok_shift_id'], $karyawan['kelompok'] );
	
			$row2[date('d',strtotime($tgl) )] =  position_text_align( $dt['kode']  , 'right');
		}
		$row3   = array(' '=> position_text_align( $detail_button  , 'right'));
		$row[] = array_merge( $row1 , $row2 , $row3);
	}
	
	$datas = table_rows($row); 
	$paging = $kgPagerOBJ ->showPaging();
	$view =  form_header( "detail pegawai" , "cp"  );
	$view .= form_field_display( '<span class="label_form">'.  date('d-m-Y' ,strtotime($periode['dari'])) .' &nbsp; s/d &nbsp; '.date('d-m-Y' ,strtotime($periode['sampai'])).'</span>'   , "<b>Periode Absen</b>"    ); 
	$view .= form_footer( );	
	$search = '<form method="GET"><input type="hidden" name="com" value="'.$_GET['com'].'" /><span style="font:10px verdana"><b>Pencarian cepat</b></span><br/><input type="text"  style="width:200px;" name="key" value="'.(isset($_GET['key']) ? $_GET['key']: "").'" /><input class="simple_search" type="submit" value=" CARI " /> </form>';
	$menuontop = array(  
			'Excel' => array('onclick'=>'javascript:location.href=\'index.php?com='.$_GET['com'].'&task=excel_data\''),
			//'Back' => array('onclick'=>'javascript:location.href=\'index.php?com='.$_GET['com'].'&rapel_id='.$rapel_id.'&task=list_komponen\''),
		);
	$printmenu = additional_menu_on_list( $menuontop ,$search);
	return  $view. $printmenu .table_builder($header , $datas ,  15 ,false ,$paging );
}


function excel_jadwal_karyawan(){
$periode_id =get_periode_absen();
	$periode = my_get_data_by_id('pr_periode','periode_id',$periode_id);
	$bulan = (int) date('m' , strtotime($periode['tanggal']));
	$tahun = (int) date('Y' , strtotime($periode['tanggal']));
	$end=$periode['tahun'].'-'. sprintf( '%02d',$bulan) .'-10' ;
	$header1 = array(
		'#'=>array('style'=>'border-bottom:2px solid;width:3%'),
		'nik'=>array('style'=>'border-bottom:2px solid;width:8%'),
		'nama'=>array('style'=>'border-bottom:2px solid;width:20%'),
		'WK'=>array('style'=>'border-bottom:2px solid;width:3%'),
		'KEL'=>array('style'=>'border-bottom:2px solid;width:3%'),
		  
	);
	$header2= array();
	$tanggals = list_kalender($periode['dari'] , $periode['sampai']  );
	$tanggals = array_unique($tanggals) ;
	foreach($tanggals as $tgl){ 
		$header2[date('d',strtotime($tgl) )] = array('style'=>'border-bottom:2px solid;width:1%');
	}
 
	$header = $header1 + $header2;
 
	$query = "
		SELECT * FROM karyawan a 
		INNER JOIN biodata b 
		ON a.biodata_id = b.biodata_id
		WHERE a.karyawan_id NOT IN (select karyawan_id FROM karyawan_disable)	
		AND a.karyawan_id NOT IN (select karyawan_id FROM pemberhentian  WHERE TMT <= '{$end}') 	
		ORDER BY a.nik
	"; 
	$result = my_query($query);
 	$i=1;
	while($ey = my_fetch_array($result )){
		$i++;
		$karyawan =  loaddata_karyawan($ey['karyawan_id']); 
		
		$detailproperty = array(
			'href'=>'index.php?com=jadwal_wk_karyawan&task=list_detail&karyawan_id='.$ey['karyawan_id'], 
			'title'=>'Detail'
		);
		$detail_button = button_icon( 'b_props.png' , $detailproperty  ); 
		$row1 = array(
			'#'=> $i, 
			'nik'=>'\''. $karyawan['nik'],   
			'nama'=>$karyawan['nama_gelar'],    
			'wk'=> $karyawan['waktu_kerja'] ,
			'kel'=>  $karyawan['kelompok'] ,   
			 
			 
		);
		$row2  = array(); 
		foreach($tanggals as $tgl){ 
			$dt = get_kelompok_jadwal($tgl  , (int)$karyawan['waktu_kerja_id'] , (int)$karyawan['kelompok_shift_id'], ($karyawan['kelompok'] =='' ?'N':$karyawan['kelompok'] ) );
	
			$row2[date('d',strtotime($tgl) )] =  position_text_align( $dt['kode']  , 'right');
		}
 
		$row[] = array_merge( $row1 , $row2 );
	}
	 
	$datas = table_rows_excel($row);  
	return table_builder_excel($header , $datas ,40 ,false ); 
}


function detail_kelompok_shift($karyawan_id  ){
	
	my_set_code_js('
		function submitChange(tanggal ,field ,value){
			location.href=\'index.php?com='.$_GET['com'].'&field=\'+field+\'&value=\'+value+\'&tanggal=\'+tanggal+\'&task=update&periode_id='.$periode_id .'&karyawan_id='.$karyawan_id.'\'  ;
		}
	');
	
	$periode_id =get_periode_absen();
	$periode = my_get_data_by_id('pr_periode','periode_id',$periode_id);
	$bulan = (int) date('m' , strtotime($periode['tanggal']));
	$tahun = $periode['tahun'] ;
	$karyawan =  loaddata_karyawan($karyawan_id,false); 
	$kelompok_shift_id =$karyawan['kelompok_shift_id'];

	$kelompok_shifts = array();
	$query_kelompok_shift = "SELECT a.jadwal_kerja_kelompok_id, 
		b.label,a.kelompok FROM a_jadwal_kerja_kelompok a 
		INNER JOIN a_waktu_kerja b ON a.waktu_kerja_id=b.waktu_kerja_id 
		ORDER BY a.jadwal_kerja_kelompok_id ";
	$re = my_query($query_kelompok_shift);
	$kelompok_shifts[21] ='X';  //sementara, untuk insert X
	while($row = my_fetch_array($re) ){
		$kelompok_shifts[$row['jadwal_kerja_kelompok_id']] =$row['label'].'/'.$row['kelompok'];
	}

	
	if($bulan =='1' ){
		$startdate = ($tahun -1).'-12-11';
		$middledata = ($tahun -1).'-12-25';
		$middledata2 = ($tahun -1).'-12-26';
		$enddate = $tahun.'-'.sprintf( '%02d',$bulan) .'-10'; 
	}else{
		$startdate = $tahun.'-'.sprintf( '%02d',$bulan-1) .'-11';
		$middledata =  $tahun .'-'.sprintf( '%02d',$bulan-1) .'-25';
		$middledata2 =  $tahun .'-'.sprintf( '%02d',$bulan-1) .'-26';
		$enddate =$tahun.'-'.$bulan .'-10'; 
	}
	$tanggals = list_kalender($startdate , $middledata  );
	$tanggals = array_unique($tanggals) ;
	
	$header = array(
		'DT'=>array('style'=>'text-align:center;border-bottom:2px solid;width:10%'),  
		'Gl.'=>array('style'=>'text-align:left;border-bottom:2px solid;width:10%'),   
		'Global Time'=>array('style'=>'text-align:left;border-bottom:2px solid;width:25%'),   
		'Schedule'=>array('style'=>'text-align:left;border-bottom:2px solid;width:15%'),   
		'S. Time'=>array('style'=>'text-align:left;border-bottom:2px solid;width:25%'),   
		'Status'=>array('style'=>'text-align:left;border-bottom:2px solid;width:15%'),   
	);
	
	$row= array();
	foreach($tanggals as $tanggal){
		$s = get_kelompok_jadwal($tanggal , 
			$karyawan['waktu_kerja_id'] , 
			$karyawan['kelompok_shift_id'], 
			$karyawan['kelompok'] );
		$r =get_realisasi_schedule($tanggal , 
			$karyawan_id, 
			(int) $karyawan['waktu_kerja_id'],
			$karyawan['kelompok'], $s['kode'],
			$karyawan['kelompok_shift_id'], 
			$kelompok_shifts ) ;
		if(get_hari_libur($tanggal)){	
			$row[] = array(
				'tanggal'=>position_text_align('<font color="red">'.date('d',strtotime($tanggal)).'</font>','center'),
				'g'=> $s['kode'],
				'stime'=>$s['jadwal'],
				'wk'=>$r['form_wk'], 
				'time'=>$r['time'], 
				'status'=>$r['status'], 
			);
		}else{
			$row[] = array(
				'tanggal'=>position_text_align(date('d',strtotime($tanggal)),'center'),
				'g'=> $s['kode'],
				'stime'=>$s['jadwal'],
				'wk'=>$r['form_wk'], 
				'time'=>$r['time'], 
				'status'=>$r['status'], 
			);
		}	
	}
	$datas = table_rows($row);
	$table1 = table_builder($header , $datas ,  2 , false);
	$tanggals = list_kalender($middledata2 ,$enddate  );
	$tanggals = array_unique($tanggals) ;
	
	$header = array(
		'DT'=>array('style'=>'text-align:center;border-bottom:2px solid;width:10%'),  
		'Gl.'=>array('style'=>'text-align:left;border-bottom:2px solid;width:10%'),   
		'Global Time'=>array('style'=>'text-align:left;border-bottom:2px solid;width:25%'),   
		'Schedule'=>array('style'=>'text-align:left;border-bottom:2px solid;width:15%'),   
		'S. Time'=>array('style'=>'text-align:left;border-bottom:2px solid;width:25%'),   
		'Status'=>array('style'=>'text-align:left;border-bottom:2px solid;width:15%'),   
	);
	
	
	$row= array();
	foreach($tanggals as $tanggal){
		$s = get_kelompok_jadwal($tanggal , 
			$karyawan['waktu_kerja_id'] , 
			$karyawan['kelompok_shift_id'], 
			$karyawan['kelompok'] );
		$r =get_realisasi_schedule($tanggal , 
			$karyawan_id, 
			(int) $karyawan['waktu_kerja_id'],
			$karyawan['kelompok'], $s['kode'],
			$karyawan['kelompok_shift_id'], 
			$kelompok_shifts ) ;
		if(get_hari_libur($tanggal)){	
			$row[] = array(
				'tanggal'=>position_text_align('<font color="red">'.date('d',strtotime($tanggal)).'</font>','center'),
				'g'=> $s['kode'],
				'stime'=>$s['jadwal'],
				'wk'=>$r['form_wk'], 
				'time'=>$r['time'], 
				'status'=>$r['status'], 
			);
		}else{
			$row[] = array(
				'tanggal'=>position_text_align(date('d',strtotime($tanggal)),'center'),
				'g'=> $s['kode'],
				'stime'=>$s['jadwal'],
				'wk'=>$r['form_wk'], 
				'time'=>$r['time'], 
				'status'=>$r['status'], 
			);
		}	
	}
	$datas = table_rows($row);
	$table2 = table_builder($header , $datas ,  2 , false);
	$kelompok = my_get_data_by_id('a_kelompok_shift','kelompok_shift_id',$kelompok_shift_id);
	 
	$newline = array(
		'Periode'=> date( 'd-m-Y' , strtotime($periode['dari']) ) .' &nbsp;  s/d &nbsp; '. date( 'd-m-Y' , strtotime($periode['sampai']) ) ,
		'Tipe Waktu Kerja'=>$karyawan['waktu_kerja'],
		'Kelompok Shift'=>strtoupper( $kelompok['kelompok_shift_kode']),
	);
	$view = karyawan_header_detail($karyawan  ,  true , $newline );
	$view .= ' <div style="width:98%;text-align:right;">
	<input type="button" value="Lihat Log" class="main_button" onclick="javascript:location.href=\'index.php?com=rpt_jadwal_wk&task=list_detail&karyawan_id='.$karyawan_id.'\'"/>
	<input type="button" value="Edit Waktu Kerja" class="main_button" style="width:180px;" onclick="javascript:jQuery.facebox({ ajax: \'index.php?com='.$_GET['com'].'&task=edit_wk&kid='.$karyawan_id .'\' });"/>  	
	<input type="button" value="Back" class="main_button" onclick="javascript:location.href=\'index.php?com=jadwal_wk_karyawan\'"/></div> '   ; 	

	$split ='<div style="height:470px;"><div style="width:49%;float:left">'.$table1.'</div>';
	$split .='<div style="width:49%;float:right">'.$table2.'</div></div>';
	return $view . $split;
}

function update_jadwal( $tanggal , $field , $value, $karyawan_id ){

	$query="SELECT realisasi_id FROM a_realisasi
		WHERE karyawan_id = {$karyawan_id} AND
		field_tgl = '{$tanggal}'";
	if (my_num_rows( my_query($query)) >0){
		$query = "UPDATE a_realisasi SET 
			{$field} ='{$value}'
			WHERE karyawan_id = {$karyawan_id} AND
			field_tgl = '{$tanggal}'";				
	}else{		
		$query = "INSERT INTO a_realisasi SET
			karyawan_id = {$karyawan_id} , {$field} ='{$value}',
			field_tgl = '{$tanggal}' ";
	}
	my_query($query);		
	return true;
}

function get_tanggal_by_periode_id(){
	$periode_id =get_periode_absen();
	$periodes = my_get_data_by_id('pr_periode','periode_id',$periode_id);
	$bulan = (int) date('m' , strtotime($periodes['tanggal']));
	$tahun = $periodes['tahun'] ;
	return sprintf( '%02d',$bulan).'-'.$tahun ;
}

function get_kelompok_jadwal($tanggal,$waktu_kerja_id,$kelompok_shift_id,$kelompok ){

	$datas = array();
	if($waktu_kerja_id>3 ){
		$kelompok=get_kelompok_shift_jadwal($tanggal, $kelompok_shift_id );
		$datas['kode'] =$kelompok;
	}else{
		if(get_hari_libur($tanggal)){	
			$datas['kode']= 'X';
		}else{
			if($waktu_kerja_id==1 ){
				$datas['kode']= 'N';
			}else{
				$datas['kode']= 'F';
			}	
		}
	}
	if($datas['kode']=="X"){
		$datas['jadwal'] = '';
	}else{
		$hari_id=get_hari_id_by_date($tanggal);
		$query = "SELECT jam_masuk,jam_pulang FROM a_jadwal_kerja 
				WHERE waktu_kerja_id = {$waktu_kerja_id} 
				AND kelompok='".$kelompok."' 
				AND hari_id={$hari_id}";
		$result = my_query($query);
		$row = my_fetch_array($result);	
		
		if( $row ){
			if($row['jam_masuk']=='00:00:00' AND $row['jam_pulang']=='00:00:00'){			
				$datas['kode'] = 'X';
			}
			$t  = date('H:i',strtotime($row['jam_masuk'])).' - '.date('H:i',strtotime($row['jam_pulang'])); 
		}else{
			$t ='';
			$datas['kode'] = ' ' ;
		}	
		$datas['jadwal'] = $t ;
	}
	return $datas;
}

function get_realisasi_schedule($tanggal , $karyawan_id, $waktu_kerja_id,  $kelompok, $kode ,$kelompok_shift_id, $kelompok_shifts){
	$r=array();
	list($yyyy,$mm,$dd) = explode("-" , $tanggal);
	$ch = "SELECT * FROM a_realisasi 
		WHERE karyawan_id = {$karyawan_id} 
			AND field_tgl='tgl_{$dd}' 
			ORDER BY realisasi_id 
			DESC LIMIT 1";
	$chr = my_query($ch);
	$row = my_fetch_array($chr);
	
	$sc_jadwal_kerja_kelompok_id=(int) $row['sc_jadwal_kerja_kelompok_id'];
	$sc_status_absen_id=(int) $row['sc_status_absen_id'];
	$sc_kelompok='0';
	if($sc_jadwal_kerja_kelompok_id==0){
		if($kode=="X"){
			$sc_jadwal_kerja_kelompok_id=21;		
		}else{	
			if($waktu_kerja_id>3){ //kelompoknya A,B.. harus dikonversi ke 1,2,3
				$kelompok=get_kalendar_shift_by_tanggal($tanggal, $kelompok_shift_id );		
			}		
			$query = "SELECT * FROM a_jadwal_kerja_kelompok 
				WHERE waktu_kerja_id = {$waktu_kerja_id}
				AND kelompok='{$kelompok}' ";
			$res = my_query($query);
			$reals = my_fetch_array($res);
			$sc_jadwal_kerja_kelompok_id=(int) $reals['jadwal_kerja_kelompok_id'];		
		}
	}
	
	$kelompok_shift = array(
		'name'=>'kelompok_shift_id',
		'id'=>'kelompok_shift_id',
		'onchange'=>'submitChange(\''.'tgl_'.$dd.'\' , \'sc_jadwal_kerja_kelompok_id\' ,this.value  )',
		'value'=>$sc_jadwal_kerja_kelompok_id  
		);
	$r['form_wk'] = form_dropdown($kelompok_shift,$kelompok_shifts) ;
	
	$r['time']=''; //init
	if($sc_jadwal_kerja_kelompok_id>0 AND $sc_jadwal_kerja_kelompok_id<21){
		$jadwal_kerja_kelompoks = my_get_data_by_id('a_jadwal_kerja_kelompok','jadwal_kerja_kelompok_id',$sc_jadwal_kerja_kelompok_id);
		$hari_id=get_hari_id_by_date($tanggal);
		$query = "SELECT jam_masuk,jam_pulang FROM a_jadwal_kerja 
				WHERE waktu_kerja_id =".$jadwal_kerja_kelompoks['waktu_kerja_id']."  
				AND kelompok='".$jadwal_kerja_kelompoks['kelompok']."' 
				AND hari_id={$hari_id}";
		$jams = my_fetch_array(my_query($query));	
		$r['time']=date('H:i',strtotime($jams['jam_masuk'])).' - '.date('H:i',strtotime($jams['jam_pulang'])); 
	}
	$statuss=get_status_absen($karyawan_id , $tanggal );
	
	$s='' ;
	foreach($statuss as $status){
		$s.=$status.', ' ;
	}
	$s=substr($s,0,strlen($s)-2) ;	
	$r['status']=$s ;

	return $r;	
}

function get_kelompok_shift_jadwal($tanggal , $kelompok_shift_id ){
	$periode_id=get_periode_absen();
	list($yyyy,$mm,$dd) = explode("-" , $tanggal);
	$query = "SELECT tgl_{$dd} FROM a_kalendar_shift 
		WHERE periode_id = {$periode_id} 
		AND kelompok_shift_id={$kelompok_shift_id}";
	$result = my_query($query);
	$re = my_fetch_array($result);
	return $re['tgl_'.$dd];
}

function get_hari_id_by_date($date){
	$hari_id=date("N",strtotime($date) ); //Monday to Sunday
	//konversi ke Sunday to Saturday
	if($hari_id==7){
		$hari_id=1;
	}else{
		$hari_id++;
	}		
	return $hari_id;
}

function get_hari_libur($date){
	if(is_sabtu_minggu($date)){
		return true;
	}
	$query="SELECT hari_libur_id FROM a_hari_libur
		WHERE tanggal = '{$date}'";
	if (my_num_rows( my_query($query)) >0){	
		return true;
	}	
	return false;
}


function form_set_waktu($id){
	$fields = my_get_data_by_id('kekaryawanan' ,'karyawan_id',$id); 
	$karyawan =  loaddata_karyawan($id);  
	$view = form_header( "..." , "..."  );
	$kelompok_shifts = array();
	$query_kelompok_shift = "SELECT a.kelompok_shift_id,b.label,a.kelompok_shift_kode FROM a_kelompok_shift a 
		INNER JOIN a_waktu_kerja b ON a.waktu_kerja_id=b.waktu_kerja_id 
		ORDER BY a.kelompok_shift_id ";
	 $re = my_query($query_kelompok_shift);
	 while($row = my_fetch_array($re) ){
		$kelompok_shifts[$row['kelompok_shift_id']] =$row['label'].'/'.$row['kelompok_shift_kode'];
	 }
	 $kelompok_shift = array(
		'name'=>'kelompok_shift_id',
		'id'=>'kelompok_shift_id',
		'value'=>isset($_POST['kelompok_shift_id']) ? $_POST['kelompok_shift_id'] : $fields['kelompok_shift_id'] 
		);
	$form_field_kelompok_shift = form_dropdown($kelompok_shift , $kelompok_shifts);
	$view .= form_field_display( $karyawan['nik']   , "NIK");
	$view .= form_field_display( $karyawan['nama']   , "Nama");
	$view .= form_field_display( $form_field_kelompok_shift   , "Tipe Waktu Kerja/Kelompok");
	$submit = array(
		'value' => ( $id ==0 ? ' Simpan ' :'  Update  '),
		'name' => 'simpan', 
		'type'=>'submit','class'=>'main_button'
	);
	$form_submit= form_dynamic($submit); 
	
	$view .= form_field_display( $form_submit  , "&nbsp;" ,  "" );
	$view .= form_footer( );
	 return  $view;
}

function submit_ubah_jadwal_wk($kid){
	$datas = array(
		'kelompok_shift_id'=>my_type_data_int($_POST['kelompok_shift_id']),
	);
	my_update_record('kekaryawanan','karyawan_id',$kid, $datas);	
	return true;
}